<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../leancloud.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/leancloud-storage/dist/av-min.js"></script>
    <link rel="stylesheet" href="../loading.css">
    <link rel="stylesheet" href="../leancloud.css">
    <style>
		html, body {
			margin: 0;
			padding: 0;
		}
		#container {
            display: flex;
            flex-wrap: wrap;
            /* justify-content: space-between; */
        }
        #container img {
            width: 100%; 
            height: 200px;
            object-fit: cover; 
            padding: 5px; 
            border-radius: 10px;
            transition: transform 0.5s;
        }
        #name {
        /* font-size: 3.2em; */
            font-weight: bold;
            margin-bottom: 5px;
            text-align: center;
        }
        #author {
            color: #666;
            margin-bottom: 5px;
            text-align: center;
        }
        img:hover {
            transform: scale(1.05);
        }
        #backButton {
            background-image: url('../images/back.png');
            width: 20px;
            height: 20px;
            background-size: cover;
            cursor: pointer;
            /* background-color: #666; */
        }
	</style>
</head>
<body>
    <div id="backButton"></div>
    <h3 id="name"></h3>
    <div id="author"></div>
    <div id="container">
        
    </div>

</body>
<script>

    var elements = document.querySelector('.post-title__text');
    elements.textContent = '今日字帖'
    
    
    var postTitle = document.querySelector('.post-title');
    postTitle.style.display = 'none';
    var headeRight = document.querySelector('.header__right');
    headeRight.style.display = 'none';
    var headeLeft = document.querySelector('.header__left');
    headeLeft.style.display = 'none';
    
    var currentPage = 1;
    var pageSize = 10; // 每页显示的条目数
    var objectId = localStorage.getItem('objectId');
    // var imgArr = localStorage.getItem('imgArr');
    var imgArr = JSON.parse(localStorage.getItem('imgArr'));
    var isLoop = localStorage.getItem('isLoop');
    var loopNum = localStorage.getItem('loopNum');
    var imgType = localStorage.getItem('imgType');
    var name = localStorage.getItem('name');
    var author = localStorage.getItem('author');
    var nameDiv = document.getElementById("name");
    nameDiv.textContent = name
    var authorDiv = document.getElementById("author");
    authorDiv.textContent = author
    var arr = [];
    if (imgArr.length == 0) {
        initLeanCloud()
        requestZitie_today_imgs(currentPage,pageSize,objectId,handleData)
        function handleData(data) {

        }
    }else{
        if (isLoop == "true") {
            let imgUrl = imgArr[0]
            for (let i = 0; i < loopNum; i++) {
                let img = imgUrl + String(i+1) + imgType
                arr.push(img)
            }
        }else{
            arr = imgArr
        }
        var container = document.getElementById("container");  
        console.log(arr);
        arr.forEach(function(object) {
                var newImg = document.createElement("img");
                newImg.classList.add("img-fluid");
                var imgurl = object
                var decodedUrl = decodeURIComponent(imgurl);
                newImg.src = decodedUrl;
                container.appendChild(newImg);
        });
    }
    var img = document.getElementById('backButton');
    img.addEventListener('click', function () {
      window.history.back()
    });
</script>
</html>